{php}$namespace = ns();{/php}
<div class="box" id="{$namespace}type2_box"></div>
<script>
    Namespace.register("EBCMS.{$namespace}type2");
    $(function(){
        EBCMS.{$namespace}type2.queryParams = {
            page:1,
            rows:20,
        };
        EBCMS.{$namespace}type2.refresh = function refresh(p){
            if (p) {
                $.each(p, function(index, val) {
                    if (typeof val == 'object') {
                        EBCMS.{$namespace}type2.queryParams[index] = $.extend(EBCMS.{$namespace}type2.queryParams[index], p[index]);
                        delete p[index];
                    };
                });
                $.extend(EBCMS.{$namespace}type2.queryParams, p);
            };
            EBCMS.CORE.load({
                url:'{:url('admin/tongji/index')}',
                queryParams:EBCMS.{$namespace}type2.queryParams,
                tpl:'{$namespace}type2-table',
                target:'#{$namespace}type2_table',
                compileAfter:function(p){
                    EBCMS.FN.renderPage({
                        namespace:'{$namespace}type2',
                        total:-1,
                    });
                    EBCMS.FN.renderFilter({
                        namespace:'{$namespace}type2',
                        filter:{
                            rows:true,
                        }
                    });
                },
            });
        };

        EBCMS.{$namespace}type2.changetime = function(times,dom){
            if (dom) {
                $(dom).addClass('active').siblings().removeClass('active');
            };
            EBCMS.{$namespace}type2.queryParams.page = 1;
            EBCMS.{$namespace}type2.refresh({
                times:times,
            });
        };

        EBCMS.CORE.compile({
            tpl:'{$namespace}type2-box',
            target:'#{$namespace}type2_box',
            compileAfter:function(){
                EBCMS.{$namespace}type2.changetime('jinri');
            }
        });
    });
</script>

<script id="{$namespace}type2-box" type="text/html">
    <div class="header">
        <div class="header-title" onclick="EBCMS.CORE.changemain('{:url('admin/tongji/index')}');">访问管理</div>
        <div class="header-title" onclick="EBCMS.CORE.changemain('{:url('admin/tongji/index?type=2')}');">页面统计</div>
        <div id="{$namespace}type2_filter" class="footer-page"></div>
        <div class="btn-group">
            <button class="btn btn-primary" onclick="EBCMS.CORE.getconfig('{:eb_encrypt('name|tongji')}');">设置</button>
        </div>
        <div class="btn-group">
            <button class="btn btn-primary active" onclick="EBCMS.{$namespace}type2.changetime('jinri',this);">今日统计</button>
            <button class="btn btn-primary" onclick="EBCMS.{$namespace}type2.changetime('zuori',this);">昨日统计</button>
            <button class="btn btn-primary" onclick="EBCMS.{$namespace}type2.changetime('benzhou',this);">本周统计</button>
            <button class="btn btn-primary" onclick="EBCMS.{$namespace}type2.changetime('shangzhou',this);">上周统计</button>
            <button class="btn btn-primary" onclick="EBCMS.{$namespace}type2.changetime('1',this);">过去一天</button>
            <button class="btn btn-primary" onclick="EBCMS.{$namespace}type2.changetime('3',this);">过去三日</button>
            <button class="btn btn-primary" onclick="EBCMS.{$namespace}type2.changetime('7',this);">过去一周</button>
            <button class="btn btn-primary" onclick="EBCMS.{$namespace}type2.changetime('30',this);">过去一月</button>
            <button class="btn btn-primary" onclick="EBCMS.{$namespace}type2.changetime('',this);">历史数据</button>
        </div>
    </div>
    <div class="body">
        <div id="{$namespace}type2_table" class="box"></div>
    </div>
    <div class="footer">
        <div id="{$namespace}type2_page" class="footer-page"></div>
    </div>
</script>

<script id="{$namespace}type2-table" type="text/html">
    <table class="table table-bordered table-hover table-ebcms">
        <tbody>
            <tr>
                <th>页面</th>
                <th>访问次数</th>
                <th>标题</th>
            </tr>
            [[include '{$namespace}type2-table-item' data]]
        </tbody>
    </table>
</script>

<script id="{$namespace}type2-table-item" type="text/html">
    [[each rows as v n]]
        <tr>
            <td>[[v.url]]</td>
            <td>[[v.num]]</td>
            <td>[[v.title]]</td>
        </tr>
    [[/each]]
</script>